import { Ref, ref, WatchStopHandle } from "vue";

export class installContentResponse implements Chaos.IActorResponse {
    public RpcId: number = 0;

    public Error: number;

    public Message: string;

    public Content: string;

    constructor(error: number = 0, message: string = '', content: string = '') {
        this.Error = error;
        this.Message = message;
        this.Content = content;
    }
}

/**
 * 安装
 */
export default class installContent {
    private static instance: installContent = new installContent();
    /**
     * 安装
     */
    public static get Default(): installContent {
        return this.instance;
    }

    constructor() {
        window.addEventListener('unload', this.Dispose.bind(this));
    }

    Dispose() {
        window.removeEventListener('unload', this.Dispose);

        for (const watchStopHandle of this.watchStopHandles) {
            watchStopHandle();
        }
        this.watchStopHandles.clear();
    }

    //安装项目数据
    public InstallProData: Ref<Array<any>> = ref([]);

    private watchStopHandles: Array<WatchStopHandle> = [];

    public async Awake(): Promise<void> {
    }

    public async Destroy(): Promise<void> {
    }
}